const CategoryModel = require("../model/CategoryModel.js");

class CategoryController {
  constructor() {
    this.categoryModel = new CategoryModel();
  }

  async getCategoryList(req, res) {
    try {
      const result = await this.categoryModel.getCategoryList();

      return res.json({
        code: 0,
        msg: "success",
        data: result,
      });
    } catch (error) {
      console.error(error.message);
      return res.status(500).json({
        code: 1,
        msg: "服务器内部错误，获取分类列表失败。",
      });
    }
  }
}

module.exports = CategoryController;
